const KEY = 'geek-h5-token'

// 直接用按需导出，可以导出多个

// 设置
export const setToken = (newToken) => {
  localStorage.setItem(KEY, newToken)
}

// 获取
export const getToken = () => {
  return localStorage.getItem(KEY)
}

// 删除
export const delToken = () => {
  localStorage.removeItem(KEY)
}

const MY_CHANNELS_KEY = 'geek-h5-my-channels'

export const setMyChannels = (myChannels) => {
  localStorage.setItem(MY_CHANNELS_KEY, JSON.stringify(myChannels))
}

export const getMyChannels = () => {
  return JSON.parse(localStorage.getItem(MY_CHANNELS_KEY))
}

export const delMyChannels = () => {
  localStorage.removeItem(MY_CHANNELS_KEY)
}
const REFRESH_TOKEN_KEY = 'geek-h5-refresh-token'

// 设置refreshToken
export const setRefreshToken = (newRefreshToken) => {
  localStorage.setItem(REFRESH_TOKEN_KEY, newRefreshToken)
}

// 获取refreshToken
export const getRefreshToken = () => {
  return localStorage.getItem(REFRESH_TOKEN_KEY)
}

// 删除refreshToken
export const delRefreshToken = () => {
  localStorage.removeItem(REFRESH_TOKEN_KEY)
}
